package com.zyl.Ecs.realtime.web.controller;

import com.zyl.Ecs.common.domain.data.bean.DataBean;
import com.zyl.Ecs.common.response.Result;
import com.zyl.Ecs.common.utils.CUtil;
import com.zyl.Ecs.realtime.service.RealTimeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.realtime.web.controller
 * @ClassName: DataUploadController
 * @Description TODO (实时数据上传接口)
 * @Author 翟玉龙
 * @Date 2024/12/6-15:42
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/data")
public class DataUploadController {

    private final RealTimeService realtimeService;

    /**
     * 上传实时数据
     *
     * @param dataEntities 数据列表
     * @return {@link Result }<{@link ? }>
     */
    @PostMapping
    public Result<?> uploadData(
            @RequestBody List<DataBean> dataEntities
    ) {
        CUtil.logInfo(String.format(
                "[Realtime]收到采集器信息：%s",
                dataEntities
        ));
        realtimeService.insert(dataEntities);
        return Result.success();
    }
}
